<?xml version="1.0"?>
<OnTheFlyInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceId>SP CSOM - WebPartManager</InstanceId>
  <CustomAppConfig />
  <Tags>
    <string>SharePoint Client</string>
  </Tags>
  <AdditionalAssemblies />
  <Code><![CDATA[// ----------------------
//  Get WebPart Manager with CSOM
// ----------------------
  
using System;
using System.Linq;
using System.Net;
using Microsoft.SharePoint.Client;
using xSolon.Instructions;

namespace xSolon.SP.ManagedClient
{
    public class SP14Client_Sample : AbstractInstruction
    {
        public override void Run()
        {
            SP14ClientHelper instr = new SP14ClientHelper();

            NetworkCredential creds = null;

            creds = new NetworkCredential("name", "password", "domain");
            
            //creds = this.CredentialCache.First();

            var ctx = instr.GetContext("http://localhost",
                SP14AuthenticationType.Windows, creds);
            
            Script(ctx, instr);
        }

        void Script(ClientContext ctx, SP14ClientHelper instr)
        {
            ctx.Load(ctx.Web);

            ctx.Load(ctx.Web.Lists);

			File file = ctx.Web.GetFileByServerRelativeUrl("/pages/biography.aspx");
			
			var wpm = file.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);
			
			var WPDefinitions = ctx.LoadQuery(wpm.WebParts.Include(w=>w.Id,w=>w.WebPart));

            ctx.ExecuteQuery();

N			otifyInformation(WPDefinitions.Count().ToString());

        }

    }
}]]></Code>
</OnTheFlyInstruction>